using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using WebControls;
using EntityLayer;
using BusinessLayer;
using InfraStructureLayer;

public partial class Admin_PersonalInstructions : SFPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            entPersonalInstruction insEntPersonalInstruction = new entPersonalInstruction();

            insEntPersonalInstruction.LanguageId = CurrentContext.LanguageId;
            busPersonalInstruction insBusPersonalInstruction = new busPersonalInstruction();
            insBusPersonalInstruction.SelectPersonalInstructionByLanguageId(insEntPersonalInstruction);
            sfiBody.HTML=insEntPersonalInstruction.PersonalInstructionBody ;
            txtTitle.Text=insEntPersonalInstruction.PersonalInstructionTitle;
            sfdLanguage.Value = CurrentContext.LanguageId;
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Validate();
        if (this.HasErrors)
        {
            MessageBoxShow(this);
            return;
        }
        entPersonalInstruction insEntPersonalInstruction = new entPersonalInstruction();
        insEntPersonalInstruction.PersonalInstructionBody = sfiBody.HTML;
        insEntPersonalInstruction.PersonalInstructionTitle = txtTitle.Text;
        insEntPersonalInstruction.LanguageId=sfdLanguage.Value.Value;
        busPersonalInstruction insBusPersonalInstruction = new busPersonalInstruction();
        insBusPersonalInstruction.UpdatePersonalInstructionByLanguageId(insEntPersonalInstruction);
        if (insBusPersonalInstruction.HasErrors)
        {
            MessageBoxShow(insBusPersonalInstruction);
            return;
        }
    }
    protected bool sfdLanguage_NeedsDataSource()
    {
        sfdLanguage.SetData(CurrentContext.Languages, "LanguageName", "LanguageId");
        return false;
    }
    protected void sfdLanguage_SelectedIndexChanged(object sender, EventArgs e)
    {
        entPersonalInstruction insEntPersonalInstruction = new entPersonalInstruction();

        insEntPersonalInstruction.LanguageId = sfdLanguage.Value.Value;
        busPersonalInstruction insBusPersonalInstruction = new busPersonalInstruction();
        insBusPersonalInstruction.SelectPersonalInstructionByLanguageId(insEntPersonalInstruction);
        sfiBody.HTML = insEntPersonalInstruction.PersonalInstructionBody;
        txtTitle.Text = insEntPersonalInstruction.PersonalInstructionTitle;
    }
}
